#最高分
i=0
scores=[34,76,92,56,76,89]
maxScores=scores[0]
for score in scores:
i=i+1
print(i,":",score)
if score>maxScores:
maxScores=score
print(maxScores)
返回值:
6.52777777777778E-02
0.136111111111111
0.188888888888889
0.205555555555556
0.261111111111111
0.311805555555556
92
求最长字符串
i=0
strongs=["hello","world","你好,世界","你是谁?","who are you?"]
longest=len(strongs[0])
for s in strongs:
i=i+1
l=len(s)
print(i,":",s)
if l>longest:
longest=s
print(longest)
返回值:
1 : hello
2 : world
3 : 你好,世界
4 : 你是谁?
5 : who are you?
who are you?